package model.forview;

import model.wrap.type.ByteElement;
import models.ConstantName;
import models.ConstantValue;

/**
 * 
 * @author pocteg
 * 
 */
public class ContentChangeByteModelForView extends ContentForMainTemplate
{

	/**
	 * ----PRIVATE-----------ATTRIBUTS-----------INSTANCE----------------------
	 */

	private ByteElement	byteElement;
	private String		remoteAddress;
	public Long		contentId;
	public byte[]		content;

	/**
	 * ----PRIVATE-----------ATTRIBUTS-----------STATIC------------------------
	 */

	/**
	 * ----PROTECTED---------ATTRIBUTS-----------INSTANCE----------------------
	 */

	/**
	 * ----PROTECTED---------ATTRIBUTS-----------STATIC------------------------
	 */

	/**
	 * ----PUBLIC------------ATTRIBUTS-----------INSTANCE----------------------
	 */

	/**
	 * ----PUBLIC------------ATTRIBUTS-----------STATIC------------------------
	 */

	/**
	 * ----CONSTRUCTORS--------------------------------------------------------
	 */

	public ContentChangeByteModelForView()
	{

	}

	/**
	 * @author pocteg
	 */
	public ContentChangeByteModelForView(ByteElement byteElement, String remoutAdress)
	{
		this.remoteAddress = remoutAdress;
		this.byteElement = byteElement;
		this.contentId = byteElement.getId();
		this.content = byteElement.getContent();
		setDefaultValues();
	}

	/**
	 * ----PRIVATE-----------METHOD-----------INSTANCE-------------------------
	 */

	/**
	 * ----PRIVATE-----------METHOD-----------STATIC---------------------------
	 */

	/**
	 * ----PROTECTED---------METHOD-----------INSTANCE-------------------------
	 */

	/**
	 * @author pocteg
	 */
	private void setDefaultValues()
	{
		String title = ConstantValue.getConstantValue(ConstantName.CONTENT_CHANGE_STRING_PAGE_TITLE);
		String header = ConstantValue.getConstantValue(ConstantName.CONTENT_CHANGE_STRING_PAGE_HEADER);
		String footer = ConstantValue.getConstantValue(ConstantName.CONTENT_CHANGE_STRING_PAGE_FOOTER);
		String userName = "";

		title = title != null ? title : "Редактирование контента";
		header = header != null ? header : "Редактирование контента";
		footer = footer != null ? footer : "Редактирование контента";

		mainModelForView = new MainModelForView(title, userName, header, footer);
	}

	/**
	 * ----PROTECTED---------METHOD-----------STATIC---------------------------
	 */

	/**
	 * ----PUBLIC------------METHOD-----------INSTANCE-------------------------
	 */

	/**
	 * ----PUBLIC------------METHOD-----------STATIC---------------------------
	 */

	/**
	 * ----GETTERS--&--SETTERS-------------------------------------------------
	 */

	/**
	 * @author pocteg
	 * @return
	 */
	public String getTitleNode()
	{
		return this.byteElement.getNode().getTitle();
	}

	/**
	 * @author pocteg
	 * @return
	 */
	public String getTitleContent()
	{
	    return this.byteElement.getTitle();
	}

	/**
	 * @author pocteg
	 * @return
	 */
	public Long getIdContent()
	{
	    return this.contentId;
	}

	/**
	 * @author pocteg
	 * @return
	 */
	public byte[] getContent()
	{
		return this.content;
	}

	/**
	 * @author pocteg
	 * @return
	 */
	public String getRemouteString()
	{
		return controllers.routes.Hierarchy.getPageNodeContentChange(this.byteElement.getNode().getId().longValue(), new Integer(0)).url();
	}

}
